extends "../../azurlane_ctrl/AzurItem.gd"
func init():
	.init()
	name = "[稀有]心之钥匙"
	info = "若佩戴者连续12场战斗没有阵亡过，则自动使其进化，进化后本道具消失\n当前进度：0/12\n变更佩戴者会重置进度"
	price = 400
	
func _connect():
	._connect()
	sys.main.connect("onBattleEnd",self,"end")
	masCha.connect("onDeath", self, "onDeath")
	num = 0

var txt = "若佩戴者连续12场战斗没有阵亡过，则自动使其进化，进化后本道具消失\n当前进度：%d/12\n变更佩戴者会重置进度"

var num = 0
func end():
	if masCha == null or masCha.evos.empty() or not utils.inBattle(masCha):return
	num += 1
	if num >= 12:
		sys.main.evoChara(masCha, sys.rndListItem(masCha.evos))
		delSelf()
	info = txt%num

func onDeath(atkInfo):
	if masCha.isDeath:
		num = 0
		info = txt%num
